package ipt.android.application.assincrono;

import ipt.android.application.HttpClient;
import ipt.android.application.constants.Acao;
import ipt.android.application.constants.Aplicacao;
import ipt.android.application.constants.MontarURI;
import ipt.android.application.constants.Servidor;

import java.io.IOException;

import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.util.EntityUtils;

import android.util.Log;

public class Logout implements Runnable {

	private String URI;
	String result = null;
	private HttpPost httpPost;
	private HttpClient request;
	private HttpResponse response;

	public Logout() {
		this.URI = MontarURI.getURI(Servidor.INDICACAO, Aplicacao.INDICACAO,
				Acao.LOGOUT);
		this.httpPost = new HttpPost(URI);
		this.request = HttpClient.getHttpCliente();
	}

	@Override
	public void run() {
		try {
			this.response = request.execute(httpPost);
			if (response.getStatusLine().equals(HttpStatus.SC_OK)) {
				this.result = EntityUtils.toString(response.getEntity());
			}
		} catch (ClientProtocolException e) {
			Log.d("ClientProtocolException", e.toString());
		} catch (IOException e) {
			Log.d("IOException", e.toString());
		}
		Log.d("Result", result);
		
	}

}
